function wxpay(app, amount_total, orderNumber, redirectUrl) {
    let remark = "在线充值";
    let nextAction = {};
  //  if (orderId != 0) {
  //    remark = "支付订单 ：" + orderId;
  //    nextAction = { type: 0, id: orderId };
  //  }
    wx.request({
        url: app.globalData.payUrl,
        data: {
            open_id: app.globalData.openIdPay,
            amount_total: amount_total,
            user_order_name: orderNumber,
            pay_type: 'user',
            backup: 'user'
        },
        header: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        //method:'POST',
        success: function (res) {
            if (res.data.code == 0) {
                // 发起支付
                wx.requestPayment({
                    timeStamp: res.data.data.timeStamp,
                    nonceStr: res.data.data.nonceStr,
                    package: 'prepay_id=' + res.data.data.prepayId,
                    signType: 'MD5',
                    paySign: res.data.data.sign,
                    fail: function (aaa) {
                        wx.showToast({ title: '支付失败' })
                    },
                    success: function () {
                        wx.showToast({ title: '支付成功' })
                        wx.redirectTo({
                            url: redirectUrl
                        });
                    },
                    complete: function (res) {
                        console.log(res);
                    },
                })
            } else {
                wx.showToast({ title: '服务器忙' + res.data.code + res.data.msg })
            }
        },
        complete: function (res) {
            console.log(res);
        },
    })
}

module.exports = {
      wxpay: wxpay
}